<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 *@author flyten
 * 用户网站信息设置，并生成配置文件 config/setting.php
 */
class Setting extends CI_Controller{
   
   
   public function __construct() {
     parent::__construct();
     $this->data['title'] = $this->config->item('setting','setting');
     $this->load->model('admin/settingModel', 'model');
   } 
   
   public function index(){
     $this->data['siteSet'] = $this->model->listA();
     $this->displayAdmin();
   }
   
   /**
    * 添加、修改功能 
    */
   public function insert(){
     $arrayPost = $this->input->post();
     $flag = 0;
     foreach( $arrayPost as $key=>$val ){
       //必须这样写，否则后面的数据会出错,详见settingmodel.php
       $data = array('setting_name'=>$key, 'setting_value'=>$val);
       $flag += $this->model->insert( $data );
     }
     $showmsg = $flag ? 'Success' : 'Faild';
     die("$showmsg");
   }
   
   
}

?>
